<?php

namespace app\admin\controller;

use think\Controller;
use app\admin\model\Admin;
use think\Session;

class Login extends Controller
{
    //
    public function index()
    {
        return view('index');
    }


    public function login($data)
    {
        $admin = Admin::get(['name'=>$data['name'],'password'=>$data['password']]);
        if($admin->name){
            Session::set("admin_user",$admin->name);
            $this->success("登录成功",'/index.php?s=/admin/index/index');
        }else{
            $this->error("登录失败");
        }

    }

    public function logout()
    {
        Session::delete("admin_user");

        $this->success("退出成功",'/index.php?s=/admin/login/index');
    }
      

}
